<template>
  <div>
    <el-row>
      <el-col :span="24" align="right">
        <div style="margin-top:10px">
                <el-input style="width:200px" v-model="filters.eventName" placeholder="事件名称"></el-input>
                <el-select style="width:200px" v-model="filters.eventTypeValue" placeholder="事件类型">
                  <el-option v-for="(v,i) of EventType" :key="i" :label="v.eventTypeName" :value="v.eventTypeValue"></el-option>
                </el-select>
          <el-button type="primary" icon="search" @click="getInfo">搜索</el-button>
          <el-button type="primary" @click="flushAll">刷新</el-button>
        </div>
        <el-row style="margin-top:20px">
          <el-col :span="$store.getters.user.userRole=='超级管理员'?3:0">
            <treeComponent style="margin-top:-52px" @GetNodeValue="GetNodeValue"></treeComponent>
          </el-col>
          <el-col :span="$store.getters.user.userRole=='超级管理员'?21:24">
            <el-table :data="list" border>
              <el-table-column type="index" width="50"></el-table-column>
              <el-table-column prop="eventName" label="事件名称" align="center"></el-table-column>
              <el-table-column prop="eventPlace" label="发生地点" align="center"></el-table-column>
              <el-table-column prop="evenScaleTypeName" label="事件规模" align="center"></el-table-column>
              <el-table-column prop="eventTypeName" label="事件类型" align="center"></el-table-column>
              <el-table-column prop="eventDate" label="发生时间" align="center"></el-table-column>
              <el-table-column prop="eventStatusName" label="事件处理状态" align="center"></el-table-column>
              <el-table-column label="操作" width="200" align="center">
                <template scope="scope">
                  <el-button size="small" v-if="scope.row.eventStatus=='06'||scope.row.eventStatus=='08'"
                    type="primary" @click="eventReview(scope.row.disputeEventID)">审核事件</el-button>
                  <el-button type="text" @click="ckDetail(scope.row.disputeEventID)">查看详情</el-button>
                </template>
              </el-table-column>
            </el-table>
             <el-pagination style="margin-top:10px;float:right" layout="prev, pager, next" :total="totalInfo"  @current-change="handleCurrentChange">
            </el-pagination>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <el-dialog title="事件审核" :visible.sync="visible">
      <el-form :model="form" label-width="220px">
        <el-form-item label="受理人" style="width:600px">
          <el-input disabled v-model="form.checkedUserID" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="审核时间">
          <el-date-picker v-model="form.checkedTime" placeholder=""></el-date-picker>
        </el-form-item>
        <el-form-item label="审核结果">
          <el-radio-group v-model="form.checkedResult">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="0">不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注" style="width:600px">
          <el-input type="textarea" v-model="form.remark" placeholder=""></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="success()">确认</el-button>
          <el-button type="warning" @click="visible = false">取消审核</el-button>
        </el-form-item>

      </el-form>
    </el-dialog>

      <el-dialog top="5%" title="查看详情" :visible.sync="visible2">
      <info :id="id"></info>
    </el-dialog>
  </div>
</template>

<script>
import treeComponent from "../../components/common/treeComponent";
import * as api from "@/api/contradictionManage/index";
import * as api3 from "../../api/securityManage";
import * as api2 from "@/api/zonghezhili/duiwujianshe";
import info from "./checkDetail"

export default {
  components: {
    treeComponent: treeComponent,
    info:info
  },
  data() {
    return {
      EventType: [],
      visible: false,
      visible2: false,
      id:"",
      filters: {
        id: 5,
        eventName: null, // 事件名称
        majorPersonName: null, // 主要当事人
        eventTypeValue: null,
        netGridID: null,
        page: 1,
        pageSize: 10
      },
      form: {
        eventID: "", //,
        checkedUserID: 5, //        bigint,
        checkedTime: "", //          datetime,
        checkedResult: "", //        int,
        remark: "" //              varchar(500),
      },
      AccidentType: [],
      AccidentKind: [],
      EventStatus: [],
      list: [
        {
          disputeEventID: "", //       bigint not null auto_increment,
          eventName: "", //             '事件名称',
          eventDate: "", //             '事件发生日期',
          eventPlace: "", //            '事件发生地点',
          evenScaleTypeValue: "", //    '事件规模',
          eventTypeValue: "", //        '事件类型编码',
          numberofJoinning: "", //      '涉及人数',
          eventIntroduction: "", //     '事件简述，不超2000字',
          relatedOrg: "", //            '涉及单位',
          majorPersonCertTypeCode: "", //'主要当事人证件代码类型，编码规范GA/T 517',
          majorPersonCertID: "", //     '主要当事人证件号码',
          majorPersonName: "", //       char(80),
          majorPersonSex: "", //        '主要当事人性别，编码符合GB/T 2261.1',
          majorPersonEthnicity: "", //  '主要当事人名族类别，详细见字典表',
          majorPersonEducation: "", //  '主要当事人学历类别，编码见表',
          majorPersonType: "", //       '主要当事人人员类别',
          majorPersonDetailAddress: "", //  '主要当事人居住详细地址',
          solvingDeadline: "", //      '化解时限',
          solvingMethodType: "", //    '化解方式，编码见 GBT 31000-2015文件之5.58',
          solvingManagment: "", //     '化解组织',
          solvingByPersonName: "", //   '化解责任人姓名',
          solvingByPersonContact: "", //'化解责任人联系方式，手机号或固定电话',
          isSuccessInSolving: "", //   '化解是否成功？值1表示成功，0表示不成功。',
          solvingIntroduction: "", //  '化解情况，不超2000字',
          evaluationDate: "", //       '考评日期，格式为YYYYMMDD',
          evaluationSuggestion: "", // '考评意见，不超2000字。',
          longitude: "", //            '地理经度信息，数字32，8',
          latitude: "", //             '地理纬度信息',
          eventStatus: "", //          '事件处理状态编码类型，见编码状态类型表',
          eventCheckStatus: "",
          netGridID: 1
        }
      ],
      totalInfo: 0,
      SolvingMethodType: []
    };
  },
  methods: {
    success() {
      let type = this.form.checkedResult == 1 ? "07" : "08";
      api.addDisputeEventChecked(this.form).then(res => {
        if (res.code == 200) {
          this.$message({
            type: "success",
            message: "审核信息上传成功!"
          });
          api.updateDisputeEventStatus(type, this.form.eventID).then(res => {
            if (res.code == 200) {
              this.$message({
                type: "success",
                message: "事件审核更新成功!"
              });
              this.getInfo();
              this.visible = false;
            } else {
              this.$message({
                type: "error",
                message: "事件审核更新失败!"
              });
            }
          });
        }
      });
    },
    eventReview(id) {
      this.form.eventID = id;
      this.visible = true;
    },
    flushAll() {
      this.filters.eventName = this.filters.eventTypeValue = null;
      if (this.$store.getters.user.userRole == "超级管理员") {
        this.filters.netGridID = null;
      }
      this.getInfo();
    },
    handleCurrentChange(val) {
      this.filters.page = val;
      this.getInfo();
    },
    ckDetail(id) {
      this.id = id;
      this.visible2 = true;
    },
    addNewRecord() {
      this.$router.push("add");
    },
    GetNodeValue(val) {
      this.filters.netGridID = val;
      this.getInfo();
    },
    editEvent(id) {
      this.$router.push({
        path: "editReview",
        query: {
          id: id
        }
      });
    },
    getInfo() {
      api.getDisputeEventAuditorQuery(this.filters).then(res => {
        this.list = res.data.disputeEvents;
        this.totalInfo = res.data.page.totalCount;
      });
      this.filters.eventName = this.filters.eventTypeValue = null;
    }
  },
  mounted() {
    this.form.checkedUserID = this.$store.getters.user.userID;
    this.filters.id = this.$store.getters.user.userID;
    if (this.$store.getters.user.userRole != "超级管理员")
      this.filters.netGridID = this.$store.getters.user.netGridID;
    this.getInfo();
    api2.fetchServedPersonManageTypes().then(res => {
      this.EventType = res.data.codeEventType;
      this.SolvingMethodType = res.data.codeSolvingMethodType;
    });
    api3.getSSEventCode().then(res => {
      this.EventStatus = res.data.EventStatusType;
    });
  }
};
</script>


<style scoped>

</style>
